import React from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { noAuthRoutes } from './authConfig';

const PrivateRoute: React.FC<{ children: JSX.Element }> = ({ children }) => {
    const token = localStorage.getItem('token');
    const location = useLocation();

    // 如果当前路由在白名单里，直接放行
    // console.log(noAuthRoutes)
    // console.log(location.pathname)
    // debugger
    // if (noAuthRoutes.includes(location.pathname)) {
    //     return children;
    // }
    return children;

    // 如果有 token，放行
    // if (token) {
    //     return children;
    // }

    // 否则跳转登录
    // return <Navigate to="/login" replace />;
};

export default PrivateRoute;
